package isg3.domain;

import java.util.Iterator;
import java.util.List;

import isg3.data.*;

public class LoginManager {
	private static LoginManager lm;

    private List users;

    public static synchronized LoginManager getInstance() {
        if (lm == null)
            lm = new LoginManager();
        return lm;
    }

    private LoginManager() {
        users = (new JDBCUsuarioDAO()).selectAllUsuario();
    }

    public List getUsuarios() {
        return users;
    }

    public Usuario getUsuario(String user) {
        Usuario result = null;
        for (Iterator iter = users.iterator(); iter.hasNext();) {
            Usuario u = (Usuario) iter.next();
            if (u.getUsuario().compareTo(user) == 0) {
                result = u;
            }
        }
        return result;
    }
}
